@extends('common.admin-master')
@section('html-header')
    <link rel="stylesheet" type="text/css" href="{{url('/css/admin/common.css')}}">
@endsection

@section('html-body')
    <div class="content">
        <div class="header">
            <h3 class="page-title">审核推广员</h3>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="well">
                    <div id="myTabContent" class="tab-content">
                        <div class="tab-pane active in" id="home" style="margin-left: 40%">
                            <ul class="fansinfo" style="list-style: none">
                                <li><em>真实姓名：</em><span>{{$fac->realname}}</span></li>
                                <li><em>联系电话：</em><span>{{$fac->telephone}}</span></li>
                                <li><em>联系QQ：</em><span>{{$fac->qq}}</span></li>
                                <li><em>联系邮箱：</em><span>{{$fac->email}}</span></li>
                                <li><em>身份证号：</em><span>{{$fac->card_num}}</span></li>
                                <li><em>邀请码：</em><span>{{$fac->invite_num}}</span></li>
                                <li><em>身份证正面：</em><span><img width="180px" height="109px" src="{{route('Api.Cardf.Show',['id'=>$fac->user_id])}}"><a href="{{route('Api.Cardf.Show',['id'=>$fac->user_id])}}" target="_blank">查看原图</a></span></li>
                                <li><em>身份证反面：</em><span><img width="180px" height="109px" src="{{route('Api.Cardb.Show',['id'=>$fac->user_id])}}"><a href="{{route('Api.Cardb.Show',['id'=>$fac->user_id])}}" target="_blank">查看原图</a></span></li>
                            </ul>
                            <div style="margin-left: 80px;margin-top: 20px">
                                @if((int)$fac->t_state == 1)
                                    <button class="btn btn-primary save"><i class="icon-ok"></i> 通过</button>
                                    <button class="btn btn-primary eventBtn"><i class="icon-remove"></i> 不通过</button>
                                @elseif((int)$fac->t_state == 3)
                                    <button class="btn btn-primary" disabled><i class="icon-remove"></i>审核不通过</button>
                                @elseif((int)$fac->t_state == 0)
                                    <button class="btn btn-primary" disabled><i class="icon-ok"></i>待用户提交审核</button>
                                @elseif((int)$fac->t_state == 2)
                                    <button class="btn btn-primary" disabled><i class="icon-ok"></i>审核已通过</button>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div  class="pop" style="display: none;">
        请告诉TA不通过的原因：
        <p><textarea id="msg"></textarea><button id="btn_send">确定</button></p>
    </div>
    <div class="mirror"  style="display: none;"></div>
    <script>
        jQuery(function() {
            var doc = document,
                    $doc = $(doc);

            function toggle() {
                $(".pop").toggle();
                $(".mirror").toggle();
            }

            $doc.on("click", ".eventBtn", function() {
                toggle();
            });

            $doc.on("click", ".mirror", function() {
                toggle();
            });

            $doc.on("click", ".pop button", function() {
                toggle();
            });

            jQuery.ajaxSetup({
                case:false,
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $doc.on('click','.save',function(){
                $.ajax({
                    type:"post",
                    url:"{{route('Api.Admin.setInvitePass')}}",
                    dataType:"json",
                    data:{
                        "facid":'{{$fac->id}}'
                    },
                    success:function(obj){
                        if(obj.level === "success"){
                            noty({text:obj.message,type:obj.level,timeout:800,
                                callback:{
                                    afterClose:function(){
                                        location.reload();
                                    }
                                }
                            });
                        }
                    },
                    error:function(obj){
                        var datajson = obj.responseJSON;
                        noty({text:datajson.message,type:datajson.level,timeout:800});
                    }
                });
            });

            $doc.on('click','#btn_send',function(){
                var msg = $('#msg').val();
                $.ajax({
                    type:"post",
                    url:"{{route('Api.Admin.inviteNoPass')}}",
                    dataType:"json",
                    data:{
                        "facid":'{{$fac->id}}',
                        "msg":msg
                    },
                    success:function(obj){
                        if(obj.level === "success"){
                            noty({text:obj.message,type:obj.level,timeout:800,
                                callback:{
                                    afterClose:function(){
                                        location.reload();
                                    }
                                }
                            });
                        }
                    },
                    error:function(obj){
                        var datajson = obj.responseJSON;
                        noty({text:datajson.message,type:datajson.level,timeout:800});
                    }
                });
            });


        });
    </script>
@endsection


